@extends('layouts.app')
@include('shop.sidebar')
@section('content')
    <div class="content">
        <div class="row custom-invoice">
            @can('shop_store_add')
            <a class="btn btn-success" href="{{ route("admin.shop.create") }}">添加门店</a>
            @endcan
            <br />
            <br />
            <div style="overflow: hidden;overflow-x: scroll;width: 1550px; -transform: scaleY(-1);">
                <table class="table table-striped table-hover" style="max-width: 2500px !important; -transform: scaleY(-1);">
                    <thead>
                    <tr>
                        <th style="min-width:150px">所属集团</th>
                        <th style="min-width:200px">门店名</th>
                        <th style="min-width:200px">标签</th>
                        <th style="min-width:250px">商品类别</th>
                        <th style="min-width:100px">状态</th>
                        <th style="min-width:300px">操作</th>
                        <th style="min-width:100px">排序权重</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $item)
                        <tr>
                            <td>
                                @if (!empty($group[$item->group_id]))
                                    {{ $group[$item->group_id] }}
                                @endif
                            </td>
                            <td>{{ $item->name }}</td>
                            <td>{{ $item->tag }}</td>
                            <td>{{ empty($item->category)?"":implode($item->category, ',') }}</td>
                            <td>{{ \App\Modules\Shop\Shop::$showStatus[$item->status] }}</td>
                            <td>
                                @can('shop_store_member')
                                    <a class="btn btn-info btn-xs" href="{{ route('admin.shop.member', ['id' => $item->id]) }}"><i class="fa fa-list-alt"></i> 会员</a>
                                @endcan
                                @can('shop_store_edit')
                                    <a class="btn btn-primary btn-xs" href="{{ route('admin.shop.edit', ['id' => $item->id]) }}"><i class="fa fa-edit"></i> 编辑</a>
                                @endcan
                                @can('shop_store_on_off')
                                    @if($item->status == \App\Modules\Shop\Shop::STATUS_CLOSE)
                                        <a class="btn btn-primary btn-xs" href="{{ route('admin.shop.status', ['id' => $item->id]) }}"><i class="fa fa-circle-o-notch"></i> 开门</a>
                                    @else
                                        <a class="btn btn-primary btn-xs" href="{{ route('admin.shop.status', ['id' => $item->id]) }}"><i class="fa fa-ban"></i> 关门</a>
                                    @endif
                                @endcan
                                @can('shop_store_recommend')
                                    <a class="btn btn-success btn-xs" href="{{ route('admin.shop.recommend', ['id' => $item->id]) }}" target="_blank"><i class="fa fa-list-alt"></i> 推荐商品</a>
                                @endcan
                            </td>
                            <td>
                                <input type="text" class="col-xs-5 change-sort" data-id="{{ $item->id }}" value="{{ $item->sort }}" />
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            {{ $data->links() }}
        </div>
    </div>
@endsection
@push('scripts')
    <script>
        $('.change-sort').on('change', function () {
            var sort = $(this).val();
            var id = $(this).attr('data-id');
            $.ajax({
                url: '{{ route('admin.shop.sort') }}',
                type: "GET",
                dataType:'json',
                data: {
                    id: id,
                    sort: sort,
                },
                success: function (re) {
                }
            });
        });

    </script>
@endpush
